<template>
	<div class="c1">
		<h1>我是Child1组件</h1>
		<h3>我收到了msg：{{msg}}</h3>
	</div>
</template>

<script>
	export default {
		name:'Child1',
		data() {
			return {
				msg:''
			}
		},
		methods: {
			death(){
				this.$destroy()
			}
		},
		mounted() {
			console.log('Child1组件挂载了')
			// console.log('##',this.x)
			this.$bus.$on('xyz',(val)=>{
				console.log('Child1组件中收到了数据',val)
				this.msg = val
			})
		},
		beforeDestroy() {
			console.log('Child1组件即将销毁')
			this.$bus.$off('xyz')
		},
	}
</script>

<style scoped>
	.c1{
		background-color: skyblue;
		padding: 20px;
	}
</style>